package com.animations;

import com.beans.TitleBean;
import creator.ui.graphics.Magicanvas;
import creator.ui.graphics.polaroid.Animation;
import java.awt.Graphics;
import java.util.ArrayList;

public class TitleAction extends Animation {

  private TitleBean title;

  public void loadBean() {
    this.title = new TitleBean();
    getBeans().add(this.title);
  }

  public void paint(Graphics g) {
    g.drawImage(
      this.title.getTitle(),
      this.title.getTitleX(),
      this.title.getTitleY0(),
      getMagicanvas()
    );
  }

  public void run() {
    int y = this.title.getTitleY0();
    int sp = 4;
    try {
      long curTime = System.currentTimeMillis();

      while (y += sp <= this.title.getTitleY1()) {
        this.title.setTitleY0(y);
        if (((curTime - System.currentTimeMillis()) % 28L == 0L) && (sp > 1)) {
          sp--;
        }
        Thread.sleep(10L);
        getMagicanvas().repaint();
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
